package com.kiln.juxingqs.dialog

import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import client.global.commlib.getScreenWidth
import com.kiln.juxingqs.R
import com.kiln.juxingqs.databinding.LayoutMsgtitledialogUpdateBinding
import com.tzstore.oo.dialog.CenterDialog

open class UpdateMsgTitleDialog(context: Context) : CenterDialog<LayoutMsgtitledialogUpdateBinding>(context) {

    var title: String = ""
    var okTxt: String = ""
    var content : String = ""
    var version : String = ""
    var versionNameTxt : String = ""
    var cancleTxt: String = "取消"
    var cancle: (() -> Unit)? = null
    var ok: (() -> Unit)? = null


    fun okClick() {
        ok?.invoke()
        cancel()
    }

    fun cancleClick() {
        cancle?.apply {
            this()
        }
        cancel()
    }

    override fun getV(): Int {
        return R.layout.layout_msgtitledialog_update
    }

    override fun postBinding() {
        binding.event = this
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (widthMode == 0)
            window?.apply {
                setGravity(Gravity.CENTER)
                val width = getScreenWidth(context)
                setLayout(
                    width * 3 / 4,
                    WindowManager.LayoutParams.WRAP_CONTENT
                )
            }

    }
}